﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.Caching;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using SalePartial.BLL;
using SalePartial.Model;
using SalePartial.Utility.WebComponents;
using System.Collections.Generic;

public partial class controls_common_webpub : System.Web.UI.UserControl
{
    //private SalePartial.BLL.SysInfo infoBll = new SalePartial.BLL.SysInfo();
    private DateTime expireTime = DateTime.Now.AddMinutes(1);

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            bind();
        }
    }

    private void bind()
    {
        string cacheKey = "webpub";
        if (Cache[cacheKey] != null)
        {
            this.pubList.DataSource = (IEnumerable)Cache[cacheKey];
        }
        else
        {
            //IList list = infoBll.GetPubInfoList();
            //Cache.Add(cacheKey, list, null, expireTime, TimeSpan.Zero, CacheItemPriority.High, null);
            //this.pubList.DataSource = list;
            List<DummyPubList> list = new List<DummyPubList>();
            list.Add(new DummyPubList(1,"热烈祝贺全球零部件网站上线1！",DateTime.Now));
            list.Add(new DummyPubList(2, "热烈祝贺全球零部件网站上线2！", DateTime.Now));
            list.Add(new DummyPubList(3, "热烈祝贺全球零部件网站上线3！", DateTime.Now));
            list.Add(new DummyPubList(4, "热烈祝贺全球零部件网站上线4！", DateTime.Now));
            list.Add(new DummyPubList(5, "热烈祝贺全球零部件网站上线5！", DateTime.Now));
            list.Add(new DummyPubList(6, "热烈祝贺全球零部件网站上线6！", DateTime.Now));
            list.Add(new DummyPubList(7, "热烈祝贺全球零部件网站上线7！", DateTime.Now));
            list.Add(new DummyPubList(8, "热烈祝贺全球零部件网站上线8！", DateTime.Now));
            list.Add(new DummyPubList(9, "热烈祝贺全球零部件网站上线9！", DateTime.Now));
            this.pubList.DataSource = list;

        }

        this.pubList.DataBind();
    }

    class DummyPubList
    {
        int id;
        string title;
        DateTime publishDate;

        public DummyPubList(int id, string title, DateTime publishDate)
        {
            this.id = id;
            this.title = title;
            this.publishDate = publishDate;
        }

        public int Id { 
            get { return id;}
            set { id = value; }
        }

        public string Title
        {
            get { return title; }
            set { title = value; }
        }

        public DateTime PublishDate
        {
            get { return publishDate; }
            set { publishDate = value; }
        }
    }
}
